package com.zhl.scheduling.controller;

import com.zhl.scheduling.model.bo.WorkpieceListQueryBO;
import com.zhl.scheduling.model.entity.Workpiece;
import com.zhl.scheduling.model.entity.WorkpieceCategory;
import com.zhl.scheduling.model.vo.ResultVO;
import com.zhl.scheduling.service.WorkpieceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author: ZhangLu In DLUT
 * @since: 1.0.0
 * @Description: 提供工件相关的操作接口
 */
@Api(value = "提供查询工件信息相关接口", tags = "工件相关")
@RestController
@CrossOrigin
@RequestMapping("/workpiece")
public class WorkpieceController {

    @Resource
    WorkpieceService workpieceService;

    @ApiOperation("根据条件获取工件列表")
    @PostMapping("/getList")
    public ResultVO getList(@RequestBody WorkpieceListQueryBO workpieceListQueryBO){
        ResultVO resultVO = workpieceService.queryByConditions(workpieceListQueryBO);
        return resultVO;
    }

    @ApiOperation("更新工件信息")
    @PostMapping("/update")
    public ResultVO update(@RequestBody Workpiece workpiece){
        return workpieceService.update(workpiece);
    }

    @ApiOperation("增加工件信息")
    @PostMapping("/add")
    public ResultVO add(@RequestBody Workpiece workpiece){
        return workpieceService.add(workpiece);
    }

    @ApiOperation("增加工件类别")
    @PostMapping("/addCategory")
    public ResultVO addCategory(@RequestBody WorkpieceCategory workpieceCategory){

        return workpieceService.addCategory(workpieceCategory);
    }
}

